# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=btyacc
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.0
pkgrel=2
pkgdesc="BackTracking Yacc (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://www.siber.com/btyacc/"
license=("custom")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc")
source=(https://www.siber.com/btyacc/${_realname}-${pkgver//./-}.tar.gz
        "0001-fix-build.patch")
sha256sums=('501be7eb21623b4bbf47f6c33f74b6dab52374939c0f155b364b1efa641b020a'
            '78f9720db28a222e96327991146c53f5a9075bf896fe972885d9d622969335a8')

prepare() {
  cd "${srcdir}"

  patch -Np0 -i "${srcdir}"/0001-fix-build.patch
}

build() {
  cd "${srcdir}"
  make all CC=$CC LINKER=$CC CFLAGS="$CFLAGS -Wno-incompatible-function-pointer-types"
}

package() {
  cd "${srcdir}"
  mkdir -p "${pkgdir}"${MINGW_PREFIX}/{bin,share}
  cp btyacc.exe "${pkgdir}"${MINGW_PREFIX}/bin/

  mkdir -p "${pkgdir}"${MINGW_PREFIX}/share/doc/${_realname}
  cp README{,.BYACC} "${pkgdir}"${MINGW_PREFIX}/share/doc/${_realname}/
}
